﻿$(function () {
	grid = $('#permissions').datagrid({
        title: '权限管理',
        methord: 'get',
        url: ''+Math.random(),
        sortName: 'ID',
        sortOrder: 'desc',
        idField: 'ID',
        pageSize: 30,
        frozenColumns: [[
	                { field: 'id', checkbox: true }
       
				]],
        columns: [[
					{ field: 'title', title: '名称', width: 150 },
					{ field: 'addTime', title: '添加日期', width: 150, sortable: true }
				]],
        fit:true,
        pagination: true,
        rownumbers: true,
        fitColumns: true,
        singleSelect: false,
        toolbar:[{
			text:'append',
			iconCls:'icon-add',
			handler:function(){
				$('#tt').datagrid('endEdit', lastIndex);
				$('#tt').datagrid('appendRow',{
					itemid:'',
					productid:'',
					listprice:'',
					unitprice:'',
					attr1:'',
					status:'P'
				});
				lastIndex = $('#tt').datagrid('getRows').length-1;
				$('#tt').datagrid('selectRow', lastIndex);
				$('#tt').datagrid('beginEdit', lastIndex);
			}
		},'-',{
			text:'delete',
			iconCls:'icon-remove',
			handler:function(){
				var row = $('#tt').datagrid('getSelected');
				if (row){
					var index = $('#tt').datagrid('getRowIndex', row);
					$('#tt').datagrid('deleteRow', index);
				}
			}
		},'-',{
			text:'accept',
			iconCls:'icon-save',
			handler:function(){
				$('#tt').datagrid('acceptChanges');
			}
		},'-',{
			text:'reject',
			iconCls:'icon-undo',
			handler:function(){
				$('#tt').datagrid('rejectChanges');
			}
		},'-',{
			text:'GetChanges',
			iconCls:'icon-search',
			handler:function(){
				var rows = $('#tt').datagrid('getChanges');
				alert('changed rows: ' + rows.length + ' lines');
			}
		}],
        onHeaderContextMenu: function (e, field) {
          
        }
    });
   
});